package mbsl.commons.lib;

/**
 * A basic element is the basis for all other elements.
 */
public class BasicElement {
	private long mId;
	private String mName;
	
	public BasicElement(long pId, String pName) {
		mId = pId;
		mName = pName;
	}

	public BasicElement() {}
	
	public long getId() {
		return mId;
	}

	public void setId(long pId) {
		mId = pId;
	}
	/**
	 * Returns the Element's name.
	 * <p>
	 * For consistency, this method will return {@code null} if:<br>
	 * {@code name.trim().isEmpty() == true}
	 */
	public String getName() {
		if (mName == null || mName.isEmpty())
			return null;
		else
			return mName;
	}
	/**
	 * Sets the Element's name.
	 */
	public void setName(String pName) {
		if (pName != null)
			pName = pName.trim();
		
		mName = pName;
	}
	
	public String toString() {
		return getName();
	}
}
